<!-- HTML header for doxygen 1.8.10-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.11"/>
<title>NATS C Client with Streaming support: Management</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
  $(window).load(resizeHeight);
</script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { init_search(); });
</script>
<link href="customdoxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectalign" style="padding-left: 0.5em;" >
   <div id="projectname">NATS C Client with Streaming support
   &#160;<span id="projectnumber">2.1.0</span>
   </div>
   <div id="projectbrief">The nats.io C Client, Supported by Synadia Communications Inc.</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.11 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="pages.html"><span>Related&#160;Pages</span></a></li>
      <li class="current"><a href="modules.html"><span>Modules</span></a></li>
      <li><a href="files.html"><span>Files</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
$(document).ready(function(){initNavTree('group__stan_conn_mgt_group.html','');});
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="summary">
<a href="#func-members">Functions</a>  </div>
  <div class="headertitle">
<div class="title">Management<div class="ingroups"><a class="el" href="group__func_group.html">Functions</a> &raquo; <a class="el" href="group__stan_conn_group.html">Streaming Connection</a></div></div>  </div>
</div><!--header-->
<div class="contents">
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:ga35e0e6e5e3b7f3818a3ac3600efb8f8f"><td class="memItemLeft" align="right" valign="top"><a class="el" href="nats_8h.html#a3bc1b3fe7f64083e60c7c3b93f205bad">NATS_EXTERN</a> <a class="el" href="status_8h.html#a36c934157b663b7b5fb5d6609c897c80">natsStatus</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__stan_conn_mgt_group.html#ga35e0e6e5e3b7f3818a3ac3600efb8f8f">stanConnection_Connect</a> (<a class="el" href="group__types_group.html#ga9e826493769d23086cfccefe95cdf64c">stanConnection</a> **sc, const char *clusterID, const char *clientID, <a class="el" href="group__types_group.html#ga13d64411878ba13a6ca39c915f2447c1">stanConnOptions</a> *options)</td></tr>
<tr class="memdesc:ga35e0e6e5e3b7f3818a3ac3600efb8f8f"><td class="mdescLeft">&#160;</td><td class="mdescRight">Connects to a <code>NATS Streaming Server</code> using the provided options.  <a href="#ga35e0e6e5e3b7f3818a3ac3600efb8f8f">More...</a><br /></td></tr>
<tr class="separator:ga35e0e6e5e3b7f3818a3ac3600efb8f8f"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga166ec494a55c9b1f9ebafd2294e05ff6"><td class="memItemLeft" align="right" valign="top"><a class="el" href="nats_8h.html#a3bc1b3fe7f64083e60c7c3b93f205bad">NATS_EXTERN</a> <a class="el" href="status_8h.html#a36c934157b663b7b5fb5d6609c897c80">natsStatus</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__stan_conn_mgt_group.html#ga166ec494a55c9b1f9ebafd2294e05ff6">stanConnection_GetNATSConnection</a> (<a class="el" href="group__types_group.html#ga9e826493769d23086cfccefe95cdf64c">stanConnection</a> *sc, <a class="el" href="group__types_group.html#gaf88dca0a18efb5c5e994d265a9f04aec">natsConnection</a> **nc)</td></tr>
<tr class="memdesc:ga166ec494a55c9b1f9ebafd2294e05ff6"><td class="mdescLeft">&#160;</td><td class="mdescRight">Returns the underlying NATS Connection.  <a href="#ga166ec494a55c9b1f9ebafd2294e05ff6">More...</a><br /></td></tr>
<tr class="separator:ga166ec494a55c9b1f9ebafd2294e05ff6"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga2e56a93825e1214a5ab688860e2a8ce6"><td class="memItemLeft" align="right" valign="top"><a class="el" href="nats_8h.html#a3bc1b3fe7f64083e60c7c3b93f205bad">NATS_EXTERN</a> void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__stan_conn_mgt_group.html#ga2e56a93825e1214a5ab688860e2a8ce6">stanConnection_ReleaseNATSConnection</a> (<a class="el" href="group__types_group.html#ga9e826493769d23086cfccefe95cdf64c">stanConnection</a> *sc)</td></tr>
<tr class="memdesc:ga2e56a93825e1214a5ab688860e2a8ce6"><td class="mdescLeft">&#160;</td><td class="mdescRight">Releases the NATS Connection.  <a href="#ga2e56a93825e1214a5ab688860e2a8ce6">More...</a><br /></td></tr>
<tr class="separator:ga2e56a93825e1214a5ab688860e2a8ce6"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga4952a7f65a53fdb5ca1c26b1a1656f1d"><td class="memItemLeft" align="right" valign="top"><a class="el" href="nats_8h.html#a3bc1b3fe7f64083e60c7c3b93f205bad">NATS_EXTERN</a> <a class="el" href="status_8h.html#a36c934157b663b7b5fb5d6609c897c80">natsStatus</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__stan_conn_mgt_group.html#ga4952a7f65a53fdb5ca1c26b1a1656f1d">stanConnection_Close</a> (<a class="el" href="group__types_group.html#ga9e826493769d23086cfccefe95cdf64c">stanConnection</a> *sc)</td></tr>
<tr class="memdesc:ga4952a7f65a53fdb5ca1c26b1a1656f1d"><td class="mdescLeft">&#160;</td><td class="mdescRight">Closes the connection.  <a href="#ga4952a7f65a53fdb5ca1c26b1a1656f1d">More...</a><br /></td></tr>
<tr class="separator:ga4952a7f65a53fdb5ca1c26b1a1656f1d"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gaea095eec18fdf04e06de16711f8b1a04"><td class="memItemLeft" align="right" valign="top"><a class="el" href="nats_8h.html#a3bc1b3fe7f64083e60c7c3b93f205bad">NATS_EXTERN</a> <a class="el" href="status_8h.html#a36c934157b663b7b5fb5d6609c897c80">natsStatus</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__stan_conn_mgt_group.html#gaea095eec18fdf04e06de16711f8b1a04">stanConnection_Destroy</a> (<a class="el" href="group__types_group.html#ga9e826493769d23086cfccefe95cdf64c">stanConnection</a> *sc)</td></tr>
<tr class="memdesc:gaea095eec18fdf04e06de16711f8b1a04"><td class="mdescLeft">&#160;</td><td class="mdescRight">Destroys the connection object.  <a href="#gaea095eec18fdf04e06de16711f8b1a04">More...</a><br /></td></tr>
<tr class="separator:gaea095eec18fdf04e06de16711f8b1a04"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<p>Functions related to connection management. </p>
<h2 class="groupheader">Function Documentation</h2>
<a class="anchor" id="ga35e0e6e5e3b7f3818a3ac3600efb8f8f"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="nats_8h.html#a3bc1b3fe7f64083e60c7c3b93f205bad">NATS_EXTERN</a> <a class="el" href="status_8h.html#a36c934157b663b7b5fb5d6609c897c80">natsStatus</a> stanConnection_Connect </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="group__types_group.html#ga9e826493769d23086cfccefe95cdf64c">stanConnection</a> **&#160;</td>
          <td class="paramname"><em>sc</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const char *&#160;</td>
          <td class="paramname"><em>clusterID</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const char *&#160;</td>
          <td class="paramname"><em>clientID</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__types_group.html#ga13d64411878ba13a6ca39c915f2447c1">stanConnOptions</a> *&#160;</td>
          <td class="paramname"><em>options</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Attempts to connect to a <code>NATS Streaming Server</code>.</p>
<p>This call is cloning the <a class="el" href="group__types_group.html#ga13d64411878ba13a6ca39c915f2447c1" title="Way to configure a stanConnection. ">stanConnOptions</a> object, if given. Once this call returns, changes made to the <code>options</code> will not have an effect to this connection. The <code>options</code> can however be changed prior to be passed to another <a class="el" href="group__stan_conn_mgt_group.html#ga35e0e6e5e3b7f3818a3ac3600efb8f8f" title="Connects to a NATS Streaming Server using the provided options. ">stanConnection_Connect()</a> call if desired.</p>
<dl class="section note"><dt>Note</dt><dd>The Streaming connection does not honor the NATS Connection option <a class="el" href="group__opts_group.html#ga20946800d024b7089e73d63454d1c19f" title="Indicates if initial connect failure should be retried or not. ">natsOptions_SetRetryOnFailedConnect()</a>. If you pass NATS Options with this option enabled, no error is returned, but if the connection cannot be established "right away", the connect call will return an error.</dd></dl>
<dl class="section see"><dt>See also</dt><dd><a class="el" href="group__types_group.html#ga13d64411878ba13a6ca39c915f2447c1" title="Way to configure a stanConnection. ">stanConnOptions</a> </dd>
<dd>
<a class="el" href="group__stan_conn_mgt_group.html#gaea095eec18fdf04e06de16711f8b1a04" title="Destroys the connection object. ">stanConnection_Destroy()</a></dd></dl>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">sc</td><td>the location where to store the pointer to the newly created <a class="el" href="group__types_group.html#gaf88dca0a18efb5c5e994d265a9f04aec" title="A connection to a NATS Server. ">natsConnection</a> object. </td></tr>
    <tr><td class="paramname">clusterID</td><td>the name of the cluster this connection is for. </td></tr>
    <tr><td class="paramname">clientID</td><td>the client ID for this connection. Only one connection with this ID will be accepted by the server. Use only a-zA-Z0-9_- characters. </td></tr>
    <tr><td class="paramname">options</td><td>the options to use for this connection (can be <code>NULL</code>). </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a class="anchor" id="ga166ec494a55c9b1f9ebafd2294e05ff6"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="nats_8h.html#a3bc1b3fe7f64083e60c7c3b93f205bad">NATS_EXTERN</a> <a class="el" href="status_8h.html#a36c934157b663b7b5fb5d6609c897c80">natsStatus</a> stanConnection_GetNATSConnection </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="group__types_group.html#ga9e826493769d23086cfccefe95cdf64c">stanConnection</a> *&#160;</td>
          <td class="paramname"><em>sc</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__types_group.html#gaf88dca0a18efb5c5e994d265a9f04aec">natsConnection</a> **&#160;</td>
          <td class="paramname"><em>nc</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>This can be used if the application needs to do non streaming messaging but does not want to create a separate NATS Connection.</p>
<p>Obtain a NATS connection from a NATS streaming connection. The NATS connection can be used to perform regular NATS operations, but it is owned and managed by the NATS streaming connection. It cannot be closed, which will happen when the NATS streaming connection is closed.</p>
<dl class="section note"><dt>Note</dt><dd>For each call to this function, the user must call <a class="el" href="group__stan_conn_mgt_group.html#ga2e56a93825e1214a5ab688860e2a8ce6" title="Releases the NATS Connection. ">stanConnection_ReleaseNATSConnection()</a> when access to the NATS Connection is no longer needed.</dd></dl>
<dl class="section warning"><dt>Warning</dt><dd>The returned connection cannot be closed, drained nor destroyed. Calling corresponding functions will have no effect or return <a class="el" href="status_8h.html#a36c934157b663b7b5fb5d6609c897c80a9bb78b4f245d2870040d25c450febd4b">NATS_ILLEGAL_STATE</a>.</dd></dl>
<dl class="section see"><dt>See also</dt><dd><a class="el" href="group__stan_conn_mgt_group.html#ga2e56a93825e1214a5ab688860e2a8ce6" title="Releases the NATS Connection. ">stanConnection_ReleaseNATSConnection()</a></dd></dl>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">sc</td><td>the pointer to the <a class="el" href="group__types_group.html#ga9e826493769d23086cfccefe95cdf64c" title="A connection to a NATS Streaming Server. ">stanConnection</a> object. </td></tr>
    <tr><td class="paramname">nc</td><td>the location where to store the pointer of the <a class="el" href="group__types_group.html#gaf88dca0a18efb5c5e994d265a9f04aec" title="A connection to a NATS Server. ">natsConnection</a> object. </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a class="anchor" id="ga2e56a93825e1214a5ab688860e2a8ce6"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="nats_8h.html#a3bc1b3fe7f64083e60c7c3b93f205bad">NATS_EXTERN</a> void stanConnection_ReleaseNATSConnection </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="group__types_group.html#ga9e826493769d23086cfccefe95cdf64c">stanConnection</a> *&#160;</td>
          <td class="paramname"><em>sc</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>This should be paired with the <a class="el" href="group__stan_conn_mgt_group.html#ga166ec494a55c9b1f9ebafd2294e05ff6" title="Returns the underlying NATS Connection. ">stanConnection_GetNATSConnection()</a> call. That is, after getting a reference to the underlying NATS Connection and once that connection is no longer needed, calling this function will allow resources to be properly released when the streaming connection is destroyed.</p>
<p>You would normally call <a class="el" href="group__stan_conn_mgt_group.html#ga166ec494a55c9b1f9ebafd2294e05ff6" title="Returns the underlying NATS Connection. ">stanConnection_GetNATSConnection()</a> and this function only once.</p>
<p>After the last <a class="el" href="group__stan_conn_mgt_group.html#ga2e56a93825e1214a5ab688860e2a8ce6" title="Releases the NATS Connection. ">stanConnection_ReleaseNATSConnection()</a> call is made, you must no longer use the NATS Connection because if <a class="el" href="group__stan_conn_mgt_group.html#gaea095eec18fdf04e06de16711f8b1a04" title="Destroys the connection object. ">stanConnection_Destroy()</a> is called, that could make the pointer to the NATS Connection invalid.</p>
<dl class="section note"><dt>Note</dt><dd>If the streaming connection is closed/destroyed before the last call to <a class="el" href="group__stan_conn_mgt_group.html#ga2e56a93825e1214a5ab688860e2a8ce6" title="Releases the NATS Connection. ">stanConnection_ReleaseNATSConnection</a>, the pointer to the NATS connection will still be valid, although all calls will fail since the connection is now closed. Calling this function will release the streaming object allowing memory to be freed.</dd></dl>
<dl class="section see"><dt>See also</dt><dd><a class="el" href="group__stan_conn_mgt_group.html#ga166ec494a55c9b1f9ebafd2294e05ff6" title="Returns the underlying NATS Connection. ">stanConnection_GetNATSConnection</a></dd></dl>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">sc</td><td>the pointer to the <a class="el" href="group__types_group.html#ga9e826493769d23086cfccefe95cdf64c" title="A connection to a NATS Streaming Server. ">stanConnection</a> object. </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a class="anchor" id="ga4952a7f65a53fdb5ca1c26b1a1656f1d"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="nats_8h.html#a3bc1b3fe7f64083e60c7c3b93f205bad">NATS_EXTERN</a> <a class="el" href="status_8h.html#a36c934157b663b7b5fb5d6609c897c80">natsStatus</a> stanConnection_Close </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="group__types_group.html#ga9e826493769d23086cfccefe95cdf64c">stanConnection</a> *&#160;</td>
          <td class="paramname"><em>sc</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Closes the connection to the server. This call will release all blocking calls. The connection object is still usable until the call to <a class="el" href="group__stan_conn_mgt_group.html#gaea095eec18fdf04e06de16711f8b1a04" title="Destroys the connection object. ">stanConnection_Destroy()</a>.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">sc</td><td>the pointer to the <a class="el" href="group__types_group.html#ga9e826493769d23086cfccefe95cdf64c" title="A connection to a NATS Streaming Server. ">stanConnection</a> object. </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a class="anchor" id="gaea095eec18fdf04e06de16711f8b1a04"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="nats_8h.html#a3bc1b3fe7f64083e60c7c3b93f205bad">NATS_EXTERN</a> <a class="el" href="status_8h.html#a36c934157b663b7b5fb5d6609c897c80">natsStatus</a> stanConnection_Destroy </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="group__types_group.html#ga9e826493769d23086cfccefe95cdf64c">stanConnection</a> *&#160;</td>
          <td class="paramname"><em>sc</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Destroys the connection object, freeing up memory. If not already done, this call first closes the connection to the server.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">sc</td><td>the pointer to the <a class="el" href="group__types_group.html#ga9e826493769d23086cfccefe95cdf64c" title="A connection to a NATS Streaming Server. ">stanConnection</a> object. </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
</div><!-- contents -->
</div><!-- doc-content -->
<!-- HTML footer for doxygen 1.8.10-->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="footer">NATS.IO Supported By Synadia Communications Inc.
    <a href="http://www.nats.io">
    </a></li>
  </ul>
</div>
</body>
</html>
